This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
Provides valid JSON for "body_json_example" feature #39
+1
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes an invalid JSON example included in the
body_json_example
feature suit:gavel-spec/features/expectations/body_json_example.feature
Lines 80 to 96 in f8224f6
The feature suit expects Gavel to throw because of the missing array member in the real body. While Gavel does throw, that happens not because of the missing array member, but because an attempt to parse the given JSON example fails (since it's invalid JSON), and body media types become the following:
Such combination of body media types has no corresponding validator in Gavel, and thus it throws an explicit error about this:
https://github.com/apiaryio/gavel.js/blob/efe1eb093d4b4433d924995088cb616100a53373/lib/mixins/validatable-http-message.js#L311-L317
Since Gavel currently stores internal exceptions and public validation results under the same
results
key, the spec assumes the thrown error is the validation error, while it's a parsing error. This is a good example why apiaryio/gavel.js#163 may be a sensible improvement in the future.